package com.dhcc.android.base.gis;

import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;

public class MultipleItemChangedManager {
	private Collection<MultipleItemChangedListener> listeners;
	/**
	 * 添加事件
	 * @param SettingsChangedListener listener
	 */
	public void addListener(MultipleItemChangedListener listener) {
		if (listeners == null) {
			listeners = new HashSet<MultipleItemChangedListener>();
		}
		listeners.add(listener);
	}
	/**
	 * 移除事件
	 * @param SettingsChangedListener listener
	 */
	public void removeListener(MultipleItemChangedListener listener) {
		if (listeners == null)
			return;
		listeners.remove(listener);
	}
	/**
	 * 触发事件
	 */
	public void fireListener(List<Integer> tar) {
		if (listeners == null)
			return;
		notifyListeners(tar);
	}
	
	/**
	 * 通知所有的
	 */
	private void notifyListeners(List<Integer> tar) {
		Iterator<MultipleItemChangedListener> iter = listeners.iterator();
		while (iter.hasNext()) {
			MultipleItemChangedListener listener = (MultipleItemChangedListener) iter.next();
			listener.doEventSettingsChanged(tar);
		}
	}
}
